package testing;

import javax.swing.JFrame;

import vis.GPoint;
import vis.GPolygon;
import vis.Scene;
import vis.TextLabel;
import vis.Viewport;
import anim.Animation;

public class Test2 {

	public static void main(String[] args) {
		JFrame frame = new JFrame("TEST");
		
		Scene scene = new Scene();
		Viewport vp = new Viewport(scene);
		
		vp.setOffset(400, 300);
/*
		GPolygon p = new GPolygon();
		p.addPoint(new GPoint(200, 200));
		p.addPoint(new GPoint(400, 300));
		p.addPoint(new GPoint(700, 100));
		p.addPoint(new GPoint(600, -300));
		p.addPoint(new GPoint(300, -100));
		p.addPoint(new GPoint(100, 0));
		scene.addObject(p);
	*/
		GPolygon p = new GPolygon();
		p.addPoint(new GPoint(100, 300));
		p.addPoint(new GPoint(400, 500));
		p.addPoint(new GPoint(600, 600));
		p.addPoint(new GPoint(800, 500));
		p.addPoint(new GPoint(700, 400));
		p.addPoint(new GPoint(600, 100));
		p.addPoint(new GPoint(500, 200));
		scene.addObject(p);
		
		GPolygon q = new GPolygon();
		q.addPoint(new GPoint(300, 400));
		//q.addPoint(new GPoint(400, 400));
		q.addPoint(new GPoint(600, 400));
		q.addPoint(new GPoint(700, 200));
		q.addPoint(new GPoint(500, 300));
		q.addPoint(new GPoint(400, 200));
		scene.addObject(q);
		
		TextLabel label = new TextLabel("");
		label.setPosition(0, 0);
		scene.addObject(label);
		
		Animation anim = new Animation(vp);
		
		frame.add(vp);
		frame.setSize(1024, 768);
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);

		
		p.checkXMonotone(anim, label);
		q.checkXMonotone(anim, label);
		q.swapHulls();
		//anim.clear();
		
		GPolygon.intersectMonotone(p, q, label, anim, scene, vp);
		vp.setOffset(100, 707);
		anim.startAnim();
	}

}
